package reducer;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * HadoopReducer
 *
 * @author zhangyimin
 * @version 1.0
 * @date 2018-07-20 上午10:03
 */
public class HadoopReducer  extends Reducer<Text,LongWritable,Text,LongWritable> {


    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
        long total=0;

        for (LongWritable l:values){
            total=total+l.get();
        }

        context.write(key,new LongWritable(total));

    }
}
